﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GCELibrary.Current;
using System.Runtime.Serialization;
namespace ZF.Model
{
    public class MTypeJsonModel
    {
        public string Name { get; set; }
        public int Type { get; set; }
        public string Values { get; set; }
        public string Def { get; set; }
    }


   
    public partial class SP_Merchandise
    {
        public string FirstPhoto
        {
            get
            {

                if (string.IsNullOrEmpty(this.Photo))
                    return "noimage.gif";
                else
                {
                    var ps = this.Photo.EmptyString("").Split(new string[] { ";" },
                         StringSplitOptions.RemoveEmptyEntries);
                    if (ps.Length > 0)
                    {
                        return ps[0];
                    }
                    else
                        return "noimage.gif";
                }


            }
        }

        public bool IsMember
        {
            get { return this.Integral > 0 && this.MPrice < this.CPrice; }
        }

        public decimal ZHPrice
        {
            get
            {
                return this.CPrice;
            }
        }
        public List<FreightSet> FreightSetList
        {
            get
            {

                return Newtonsoft.Json.JsonConvert.DeserializeObject<List<FreightSet>>(this.FreightSet);

            }
        }
    }
     
    [Serializable]
    public partial class SP_Order
    {
        public decimal ZHPrice
        {
            get
            {
                var d = Decimal.Round((decimal)((decimal)this.OPrice * this.Discount / (decimal)10), 2);
                return d;
            }
        }
        public string StatusName
        {
            get
            {
                switch ((OrderStatus)this.Status)
                {
                    case OrderStatus.下单10:
                        return "订单待确认";
                    case OrderStatus.确认20:
                        return "订单已确认";
                    case OrderStatus.处理中30:
                        return "正在处理订单";
                    case OrderStatus.订单已完成40:
                        return "订单已完成";
                    case OrderStatus.作废50:
                        return "订单作废";
                }
                return "";
            }
        }

        public string PayTypeName
        {
            get
            {
                var pt = (PayType)PayType;
                switch (pt)
                {
                    case Model.PayType.ZFB:
                        return "支付宝";
                    case Model.PayType.ToPay:
                        return "货到付款";
                    case Model.PayType.Bank:
                        return "银行转帐";
                }
                throw new Exception("支付方式枚举错误");

            }
        }
    }


    public partial class I_Info
    {
        public string FirstPhoto
        {
            get
            {

                if (string.IsNullOrEmpty(this.Photo))
                    return "noimage.gif";
                else
                {
                    var ps = this.Photo.EmptyString("").Split(new string[] { ";" },
                         StringSplitOptions.RemoveEmptyEntries);
                    if (ps.Length > 0)
                    {
                        return ps[0];
                    }
                    else
                        return "noimage.gif";
                }


            }
        }
    }

    public partial class H_House
    {
        public string FirstPhoto
        {
            get
            {

                if (string.IsNullOrEmpty(this.Photo))
                    return "noimage.gif";
                else
                {
                    var ps = this.Photo.EmptyString("").Split(new string[] { ";" },
                         StringSplitOptions.RemoveEmptyEntries);
                    if (ps.Length > 0)
                    {
                        return ps[0];
                    }
                    else
                        return "noimage.gif";
                }


            }
        }
    }
    public partial class H_Estate
    {
        public string FirstPhoto
        {
            get
            {

                if (string.IsNullOrEmpty(this.Photo))
                    return "noimage.gif";
                else
                {
                    var ps = this.Photo.EmptyString("").Split(new string[] { ";" },
                         StringSplitOptions.RemoveEmptyEntries);
                    if (ps.Length > 0)
                    {
                        return ps[0];
                    }
                    else
                        return "noimage.gif";
                }


            }
        }
    }
    public class FreightSet
    {
        public FreightSet(int type, decimal price)
        {
            this.Type = type;
            this.Price = price;
        }
        /// <summary>
        /// 1平邮\2快递\3EMS\4货送
        /// </summary>
        public int Type { get; set; }
        public decimal Price { get; set; }
        public string Name
        {
            get
            {
                return GetNameByType(this.Type);


            }
        }
        public static string GetNameByType(int type)
        {
            switch (type)
            {
                case 1:
                    return "平邮";
                case 2:
                    return "快递";
                case 3:
                    return "EMS";
                case 4:
                    return "货送";
                default:
                    return "";
            }
        }
    }
    /// <summary>
    /// 下单10 = 10,
    ///      确认20 = 20,
   ///       处理中30 = 30,
     ///     订单已完成40 = 40,
    ///     失效50 = 50
    /// </summary>
    public enum OrderStatus
    {
        下单10 = 10,
        确认20 = 20,
        处理中30 = 30,
        订单已完成40 = 40,
        作废50 = 50
    }
    /// <summary>
    /// 支付状态
    /// </summary>
    public enum PayStatus
    {
        /// <summary>
        /// 新交易(默认)
        /// </summary>
        NEW_PAY=0,// 新交易(默认)
        /// <summary>
        /// 交易创建 
        /// </summary>
        WAIT_BUYER_PAY=1,//  ◆交易创建 
        /// <summary>
        /// 支付成功，标准即时到账成功状态 
        /// </summary>
        TRADE_FINISHED=2,//  ◆支付成功，标准即时到账成功状态 
        /// <summary>
        /// 支付成功，高级即时到账返回成功状态 
        /// </summary>
        TRADE_SUCCESS=3,//  ◆支付成功，高级即时到账返回成功状态 
        /// <summary>
        /// 交易关闭 
        /// </summary>
        TRADE_CLOSED=4,//  ◆交易关闭 
    }
    public enum PayType
    {
        /// <summary>
        /// 支付宝
        /// </summary>
        ZFB = 1,
        /// <summary>
        /// 到付
        /// </summary>
        ToPay = 2,
        /// <summary>
        /// 银行转帐
        /// </summary>
        Bank=3,
    }

    public enum ArticleType : int
    {
        我的文章 = 1,
        贷款种类 = 2,
        合作银行 = 3,
        学术研究 = 4,
        案例分析 = 5,
        设计理念 = 6,
        设计案例 = 7
    }

}
